/*
 *      main.c
 *
 *      Copyright 2007 Giulio Bai <giulio@hewle.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <config.h>
#include <io2.h>
#include <video.h>
#include <gdt.h>
#include <idt.h>
#include <isr.h>
#include <irq.h>
#include <kbd.h>
#include <timer.h>

void kmain (void)
{
	vid_init ();
	gdt_start ();
	idt_install ();
	isr_install ();
	irq_install ();
		
	/* Allow IRQs to happen.
	 * To deisable IRQs just send 'cli' though an asm call */
	__asm__ __volatile__ ("sti");
	
	/* Install timer first, or the keyboard handler won't wor!
	 * (it needs the timer!) */
	timer_install (1);
	keyboard_load ();
	
	/* This just says to print something like
	 * (2nd arg)(1st arg) (3rd arg)
	 * starting kernel...   [ OK ] */
	printi ("kernel", 1, 1);
	
	/* Set foreground color to cyan */
	vid_set_color (11, 0);
	puts ("\n\tABX 0.1");
	
	/* Reset colors */
	vid_set_color_reset ();
	printf (" has been successfully loaded on %s at %i:%i:%i\n", "localhost", 15, 18, 11);
	
	puts ("\thttp://abx.sourceforge.net\n\n");
	puts ("Copyright (C)2007 Giulio Bai <giulio@hewle.com>\n");
	puts ("Distributed under the terms of the GNU General Public License (GPL)\n\n");
	
	/* Creates default shell */
	init_shell ();
	
	while (1);
}
